﻿using System;
using UnityEngine;
using UnityEngine.UI;

namespace SizeboxUI
{
	// Token: 0x0200039F RID: 927
	public class EditView : MonoBehaviour
	{
		// Token: 0x170003A9 RID: 937
		// (get) Token: 0x0600183C RID: 6204 RVA: 0x000997E6 File Offset: 0x000979E6
		// (set) Token: 0x0600183D RID: 6205 RVA: 0x000997EE File Offset: 0x000979EE
		public EditPlacement placement { get; private set; }

		// Token: 0x170003AA RID: 938
		// (get) Token: 0x0600183E RID: 6206 RVA: 0x000997F7 File Offset: 0x000979F7
		// (set) Token: 0x0600183F RID: 6207 RVA: 0x000997FF File Offset: 0x000979FF
		public SceneTreeView sceneTreeView { get; private set; }

		// Token: 0x170003AB RID: 939
		// (get) Token: 0x06001840 RID: 6208 RVA: 0x00099808 File Offset: 0x00097A08
		// (set) Token: 0x06001841 RID: 6209 RVA: 0x00099810 File Offset: 0x00097A10
		public InterfaceControl control { get; private set; }

		// Token: 0x170003AC RID: 940
		// (get) Token: 0x06001842 RID: 6210 RVA: 0x00099819 File Offset: 0x00097A19
		// (set) Token: 0x06001843 RID: 6211 RVA: 0x00099821 File Offset: 0x00097A21
		public CommandView actionSelector { get; private set; }

		// Token: 0x06001844 RID: 6212 RVA: 0x0009982C File Offset: 0x00097A2C
		private void Awake()
		{
			this.controller = Camera.main.GetComponent<GameController>();
			this.mainView = this.controller.view;
			this.placement = this.controller.GetComponent<EditPlacement>();
			this.control = this.controller.GetComponent<InterfaceControl>();
			this.transformView = UnityEngine.Object.Instantiate<GameObject>(Resources.Load("UI/Transform") as GameObject);
			this.transformView.transform.SetParent(base.transform, false);
			this.sceneTreeView = UnityEngine.Object.Instantiate<GameObject>(Resources.Load("UI/Edit/SceneTree/SceneTree") as GameObject).AddComponent<SceneTreeView>();
			this.sceneTreeView.transform.SetParent(base.transform, false);
			this.sceneTreeView.gameObject.SetActive(false);
			this.catalogView = UnityEngine.Object.Instantiate<GameObject>(Resources.Load("UI/Catalog") as GameObject).AddComponent<CatalogView>();
			this.catalogView.transform.SetParent(base.transform, false);
			this.poseView = UnityEngine.Object.Instantiate<GameObject>(Resources.Load("UI/Pose/Pose") as GameObject).AddComponent<PoseView>();
			this.poseView.transform.SetParent(base.transform, false);
			this.animationView = UnityEngine.Object.Instantiate<GameObject>(Resources.Load("UI/Animation") as GameObject).AddComponent<AnimationView>();
			this.animationView.transform.SetParent(base.transform, false);
			this.morphsView = UnityEngine.Object.Instantiate<GameObject>(Resources.Load("UI/Morphs") as GameObject).AddComponent<MorphsView>();
			this.morphsView.transform.SetParent(base.transform, false);
			this.characterEditor = UnityEngine.Object.Instantiate<GameObject>(Resources.Load("UI/CharacterEditor") as GameObject);
			this.characterEditor.transform.SetParent(base.transform, false);
			this.actionSelector = UnityEngine.Object.Instantiate<GameObject>(Resources.Load("UI/Command") as GameObject).AddComponent<CommandView>();
			this.actionSelector.transform.SetParent(base.transform, false);
			this.button = (Resources.Load("UI/Button/EditButton") as GameObject);
			this.panel = base.transform.GetChild(0);
			Button button = this.AddButton("Play");
			button.onClick.AddListener(delegate()
			{
				this.mainView.ChangeMode();
			});
			button = this.AddButton("Scene");
			button.onClick.AddListener(delegate()
			{
				this.OnSceneClick();
			});
			button = this.AddButton("Giantess");
			button.onClick.AddListener(delegate()
			{
				this.OnCatalogClick(1);
			});
			button = this.AddButton("Micro");
			button.onClick.AddListener(delegate()
			{
				this.OnCatalogClick(3);
			});
			button = this.AddButton("Objects");
			button.onClick.AddListener(delegate()
			{
				this.OnCatalogClick(0);
			});
			button = this.AddButton("Move");
			button.onClick.AddListener(delegate()
			{
				this.placement.MoveCurrentGO();
			});
			button = this.AddButton("Transform");
			button.onClick.AddListener(delegate()
			{
				this.OnTransformClick();
			});
			button = this.AddButton("Animation");
			button.onClick.AddListener(delegate()
			{
				this.OnAnimationClick();
			});
			button = this.AddButton("Pose");
			button.onClick.AddListener(delegate()
			{
				this.OnPoseClick();
			});
			button = this.AddButton("Morphs");
			button.onClick.AddListener(delegate()
			{
				this.OnMorphsClick();
			});
			button = this.AddButton("Model");
			button.onClick.AddListener(delegate()
			{
				this.OnCharacterClick();
			});
			button = this.AddButton("Delete");
			button.onClick.AddListener(delegate()
			{
				this.placement.Delete();
			});
			button = this.AddButton("Menu");
			button.onClick.AddListener(delegate()
			{
				this.controller.view.OpenPauseMenu();
			});
		}

		// Token: 0x06001845 RID: 6213 RVA: 0x00099C24 File Offset: 0x00097E24
		public void OnTransformClick()
		{
			this.transformView.SetActive(!this.transformView.activeSelf);
			if (this.transformView.activeSelf && this.sceneTreeView.gameObject.activeSelf)
			{
				this.sceneTreeView.gameObject.SetActive(false);
			}
		}

		// Token: 0x06001846 RID: 6214 RVA: 0x00099C80 File Offset: 0x00097E80
		public void OnSceneClick()
		{
			this.sceneTreeView.gameObject.SetActive(!this.sceneTreeView.gameObject.activeSelf);
			if (this.transformView.activeSelf && this.sceneTreeView.gameObject.activeSelf)
			{
				this.transformView.SetActive(false);
			}
		}

		// Token: 0x06001847 RID: 6215 RVA: 0x00099CE4 File Offset: 0x00097EE4
		public void OnCatalogClick(int category)
		{
			if (category == 2 && (this.control.selectedEntity == null || !this.control.selectedEntity.isGiantess))
			{
				return;
			}
			bool activeSelf = this.catalogView.gameObject.activeSelf;
			this.DisablePrimaryViews();
			this.catalogView.gameObject.SetActive(activeSelf);
			this.catalogView.OnMenuClick(category);
			this.transformView.SetActive(true);
			if (this.transformView.activeSelf && this.sceneTreeView.gameObject.activeSelf)
			{
				this.sceneTreeView.gameObject.SetActive(false);
			}
		}

		// Token: 0x06001848 RID: 6216 RVA: 0x00099D9C File Offset: 0x00097F9C
		public void OnAnimationClick()
		{
			if (this.control.humanoid == null)
			{
				return;
			}
			bool activeSelf = this.animationView.gameObject.activeSelf;
			this.DisablePrimaryViews();
			this.animationView.gameObject.SetActive(!activeSelf);
			this.transformView.SetActive(true);
			if (this.transformView.activeSelf && this.sceneTreeView.gameObject.activeSelf)
			{
				this.sceneTreeView.gameObject.SetActive(false);
			}
		}

		// Token: 0x06001849 RID: 6217 RVA: 0x00099E30 File Offset: 0x00098030
		public void OnPoseClick()
		{
			if (this.control.humanoid == null)
			{
				return;
			}
			bool activeSelf = this.poseView.gameObject.activeSelf;
			this.DisablePrimaryViews();
			this.poseView.gameObject.SetActive(!activeSelf);
			this.transformView.SetActive(true);
			if (this.transformView.activeSelf && this.sceneTreeView.gameObject.activeSelf)
			{
				this.sceneTreeView.gameObject.SetActive(false);
			}
		}

		// Token: 0x0600184A RID: 6218 RVA: 0x00099EC4 File Offset: 0x000980C4
		public void OnMorphsClick()
		{
			if (this.control.selectedEntity == null || !this.control.selectedEntity.isGiantess)
			{
				return;
			}
			bool activeSelf = this.morphsView.gameObject.activeSelf;
			this.DisablePrimaryViews();
			this.morphsView.gameObject.SetActive(!activeSelf);
		}

		// Token: 0x0600184B RID: 6219 RVA: 0x00099F28 File Offset: 0x00098128
		public void OnCharacterClick()
		{
			if (this.control.selectedEntity == null)
			{
				return;
			}
			bool activeSelf = this.characterEditor.gameObject.activeSelf;
			this.DisablePrimaryViews();
			this.characterEditor.gameObject.SetActive(!activeSelf);
		}

		// Token: 0x0600184C RID: 6220 RVA: 0x00099F78 File Offset: 0x00098178
		private void DisablePrimaryViews()
		{
			this.animationView.gameObject.SetActive(false);
			this.catalogView.gameObject.SetActive(false);
			this.poseView.gameObject.SetActive(false);
			this.morphsView.gameObject.SetActive(false);
			this.characterEditor.gameObject.SetActive(false);
		}

		// Token: 0x0600184D RID: 6221 RVA: 0x00099FDC File Offset: 0x000981DC
		public Button AddButton(string label)
		{
			GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.button, this.panel);
			gameObject.name = label;
			gameObject.GetComponent<Text>().text = label;
			return gameObject.GetComponent<Button>();
		}

		// Token: 0x0600184E RID: 6222 RVA: 0x0009A014 File Offset: 0x00098214
		public void OnDeleteClick()
		{
			this.sceneTreeView.DeleteSelectedEntries();
			if (this.placement.control != null)
			{
				this.placement.Delete();
			}
		}

		// Token: 0x0600184F RID: 6223 RVA: 0x0009A044 File Offset: 0x00098244
		private void OnEnable()
		{
			Cursor.lockState = CursorLockMode.None;
			if (GlobalPreferences.SL_OpenOnEditor.value && !this.transformView.activeSelf && !this.sceneTreeView.gameObject.activeSelf)
			{
				this.OnSceneClick();
			}
		}

		// Token: 0x06001850 RID: 6224 RVA: 0x0009A091 File Offset: 0x00098291
		private void OnDisable()
		{
			Cursor.lockState = CursorLockMode.Locked;
		}

		// Token: 0x04001A6A RID: 6762
		private GameController controller;

		// Token: 0x04001A6B RID: 6763
		private MainView mainView;

		// Token: 0x04001A6C RID: 6764
		private GameObject button;

		// Token: 0x04001A6D RID: 6765
		private Transform panel;

		// Token: 0x04001A70 RID: 6768
		private GameObject transformView;

		// Token: 0x04001A71 RID: 6769
		private CatalogView catalogView;

		// Token: 0x04001A72 RID: 6770
		private AnimationView animationView;

		// Token: 0x04001A73 RID: 6771
		private MorphsView morphsView;

		// Token: 0x04001A74 RID: 6772
		private PoseView poseView;

		// Token: 0x04001A75 RID: 6773
		private GameObject characterEditor;
	}
}
